Repository navigation
Conversation
akx
requested changes
Oct 26, 2026
akx
left a comment
Member
There was a problem hiding this comment.
The idea is good, but please clean up the comments -- 2026-10-10 doesn't mean much especially since it's already 2026-10-26 as I'm reviewing this...
| msgid = message.id.encode(catalog.charset) | ||
| msgstr = message.string.encode(catalog.charset) | ||
| if message.context: | ||
| # 2026-10-10: An empty context differs from an absent context. |
Member
There was a problem hiding this comment.
Suggested change
| # 2026-10-10: An empty context differs from an absent context. | |
| # An empty context differs from an absent context. |
Comment on lines
+685
to
+686
| # 2026-10-10: Preserve explicitly empty contexts. | ||
| if message.context is not None: |
Member
There was a problem hiding this comment.
Suggested change
| # 2026-10-10: Preserve explicitly empty contexts. | |
| if message.context is not None: | |
| if message.context is not None: # Preserve explicitly empty contexts. |
Comment on lines
+698
to
+699
| # 2026-10-10: Preserve explicitly empty contexts. | ||
| if message.context is not None: |
Member
There was a problem hiding this comment.
Suggested change
| # 2026-10-10: Preserve explicitly empty contexts. | |
| if message.context is not None: | |
| if message.context is not None: # Preserve explicitly empty contexts. |
|
|
||
|
|
||
| def test_empty_message_context(): | ||
| # 2026-10-10: Empty contexts must remain distinct from absent contexts. |
Member
There was a problem hiding this comment.
Suggested change
| # 2026-10-10: Empty contexts must remain distinct from absent contexts. | |
| """ | |
| Test that empty contexts remain distinct from absent contexts. | |
| See https://www.gnu.org/software/gettext/manual/html_node/Entries-with-Context.html: | |
| > Note that an empty context string and an absent msgctxt line do not mean the same thing. | |
| """ |
| assert output["foo"].string in ((''), ('', '')) | ||
|
|
||
|
|
||
| # 2026-10-10: PO roundtrips must preserve empty singular and plural contexts. |
Member
There was a problem hiding this comment.
Suggested change
| # 2026-10-10: PO roundtrips must preserve empty singular and plural contexts. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GNU gettext distinguishes an empty context from an absent msgctxt, and Catalog stores both entries separately. The PO and MO writers currently omit an empty context, so messages sharing an ID are merged or lost when the output is read. Check whether context is None in the regular singular/plural serialization branches. Add PO/MO roundtrips for absent, empty, and named contexts, and verify translated lookup results.
Validation: all three new regressions fail before the change; 41 PO/MO tests and the complete suite (7,831 passed, 10 skipped, 2 xfailed) pass afterward. Project Ruff checks, whitespace/debug hooks, and sdist/wheel builds passed. Tests use the Makefile's python -X utf8 flag and the project's imported CLDR 48.2 data.
Specification: https://www.gnu.org/software/gettext/manual/html_node/Entries-with-Context.html